using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Mapping
{
	public class Tb_Temp_FinanceMap : EntityTypeConfiguration<Tb_Temp_Finance>
	{
		public Tb_Temp_FinanceMap()
		{
			// Primary Key
			this.HasKey(t => t.id);

			// Properties
			this.Property(t => t.mssv)
				.IsRequired()
				.IsFixedLength()
				.HasMaxLength(10);
				
			this.Property(t => t.fullname)
				.IsFixedLength()
				.HasMaxLength(50);
				
			this.Property(t => t.listcource)
				.HasMaxLength(255);
				
			// Table & Column Mappings
			this.ToTable("Tb_Temp_Finance");
			this.Property(t => t.id).HasColumnName("id");
			this.Property(t => t.id_student).HasColumnName("id_student");
			this.Property(t => t.mssv).HasColumnName("mssv");
			this.Property(t => t.fullname).HasColumnName("fullname");
			this.Property(t => t.id_term).HasColumnName("id_term");
			this.Property(t => t.listcource).HasColumnName("listcource");
			this.Property(t => t.totalcerdit).HasColumnName("totalcerdit");
			this.Property(t => t.totalmoney).HasColumnName("totalmoney");

			// Relationships
			this.HasRequired(t => t.Tb_Config)
				.WithMany(t => t.Tb_Temp_Finance)
				.HasForeignKey(d => d.id_term);
				
			this.HasRequired(t => t.Tb_People)
				.WithMany(t => t.Tb_Temp_Finance)
				.HasForeignKey(d => d.id_student);
				
		}
	}
}

